package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.ReservationInfo;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Order;
import com.itheima.health.service.OrderService;
import com.itheima.health.service.OrderSettingService;
import com.itheima.health.vo.OrderSubmitParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 预约控制器
 */
@RestController
@RequestMapping("/mobile/order")
@Slf4j
public class MobileOrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderSettingService orderSettingService;


    /**
     *   体检预约 提交
     * @param orderSubmitParam
     * @return
     */
    @PostMapping("/submit")
    public Result submit(@RequestBody OrderSubmitParam orderSubmitParam){
        Order order = orderService.submitOrder(orderSubmitParam);
        return new Result(true,MessageConst.ORDER_SUCCESS,order);
    }

    /**
     *  体检预约 数据展示
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result findById(String id){
        ReservationInfo reservationInfo = orderService.findById(id);
        return new Result(true,MessageConst.QUERY_ORDER_SUCCESS,reservationInfo);
    }



}
